//
//  ViewController.m
//  PresentVIewController
//
//  Created by student on 16/2/24.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"
#import "DViewController.h"
#import "EViewController.h"
#import "BViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//当沿着Storyboard中的连线跳转的时候触发的方法
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//    NSLog(@"%@",segue.identifier);// 连线的名字
//    NSLog(@"%@",segue.destinationViewController);// 连线的目标是哪个控制器
   if([segue.identifier isEqualToString:@"popB"])
   {
       BViewController *bVC = segue.destinationViewController;
       // 错误!当前处于正要弹出的状态，vcB对象创建了，但是视图还没有创建初始化
       // vcB.resultLabel 界面对象还没有显示出来，还是空对象
       // vcB.resultLabel.text = [NSString stringWithFormat:@"%i",[self.numTextField.text intValue] * 10];
       bVC.num = [self.numTextFiled.text intValue]*10;
   }
}

//沿着某跟连线跳转
- (IBAction)popCBtnPressed:(id)sender
{
    [self performSegueWithIdentifier:@"popC" sender:nil];
}
- (IBAction)popDBtnPressed:(id)sender
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    DViewController *dVC = [sb instantiateViewControllerWithIdentifier:@"dVC"];
    [self presentViewController:dVC animated:YES completion:nil];

    
}
- (IBAction)popEBtnPressed:(id)sender
{
    EViewController *eVC = [[EViewController alloc]init];
    eVC.modalPresentationStyle = UIModalPresentationFullScreen;
    eVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    // 奇幻动画方式
    //    UIModalTransitionStyleCoverVertical = 0,
    //    UIModalTransitionStyleFlipHorizontal __TVOS_PROHIBITED,
    //    UIModalTransitionStyleCrossDissolve,
    //    UIModalTransitionStylePartialCurl NS_ENUM_AVAILABLE_IOS(3_2) __TVOS_PROHIBITED,
   // 代码弹出视图控制器对象
    // 直接赋值，把数据传递过去
    eVC.num = [self.numTextFiled.text intValue] * 10;
    
    [self presentViewController:eVC animated:YES completion:nil];

    
}

// 触摸开始的时候触发的方法，当前视图属于UIView类,UIView从UIResponder继承了这个方法
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    // 关闭键盘
    //    [self.view endEditing:YES];
    
    [self.numTextFiled resignFirstResponder];
}

@end
